package cn.edu.zafu.bigdata.lb;
/**
 * ArithmeticExceptionExample - 处理算术异常的示例程序
 * @author LiuBo
 */
public class ArithmeticExceptionExample {

    public static void main(String[] args) {
        try {
            int result = divide(10, 0);
            System.out.println("结果是: " + result);
        } catch (ArithmeticException e) {
            System.out.println("错误: " + e.getMessage());
        }
    }

    public static int divide(int a, int b) {
        if (b == 0) {
            throw new ArithmeticException("分母不能为0");
        }
        return a / b;
    }
}